#!/bin/bash
#https://www.lifewire.com/pass-arguments-to-bash-script-2200571

COMPILEMODE=$1
PROJECT=$2

rm -rf bin/*
if [ -d ./build ] ; then
    echo "Delete the content of build forld"
    rm -rf build/*
else
    echo "Make build diretory..."
    mkdir -p build
    mkdir -p bin
fi

find ./ -name "CMakeLists.txt" | xargs rm -rf 

if [ "$COMPILEMODE" == "release" ] ; then
    echo "build release version ..."
    python3 script/CMakeLists.py release $PROJECT
else
    echo "build debug version ..."
    python3 script/CMakeLists.py debug $PROJECT
fi

cd build && cmake ..
cd .. && make -C build

